import util.ListNode;

/**
 * Created by loso on 2017/3/9.
 */
public class _83_RemoveDuplicatesFromSortedList {
//去除链表中的元素
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null)
            return null;
        ListNode oiragno = head;

        ListNode oldNode = head;
        head = head.next;
        while(head != null){

            while (head != null && oldNode.val == head.val ){
                head = head.next;
                oldNode.next = head;
            }
            oldNode = head;
            if(head == null)
                break;
            head = head.next;
        }

        return oiragno;
    }

}
